package com.springcloud.eurekaclient.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {
    @Value("${server.port}")
    String port;

    @RequestMapping("/hi")
    @ResponseBody
    public String homeForRequestParam(@RequestParam(value = "name", defaultValue = "forezp") String name) {
        return "homeForRequestParam:  hi " + name + " ,i am from port:" + port;
    }

    @RequestMapping("/hi/{name}")
    @ResponseBody
    public String homeForPathVariable(@PathVariable(value = "name") String name) {
        return "homeForPathVariable:  hi " + name + " ,i am from port:" + port;
    }
}
